export default class orc_data extends Laya.Script {
    public static local_data = {        
        "user_level":1,
        "money":0,
    };

    public static memory_data = {
        "user_id":"",
        "user_guest":true,
        "widget_scale":1,           //屏幕自适应参数
    };

    public static config_data:any = {};

    public static save_local_data(){
        let save_data:any = {};
        let session_key =  "orc_" + orc.orc_config.PLATFORM + "_" + orc.orc_config.GAME_NAME;
        save_data[session_key] = {};
        console.log('session_key',session_key);
        for (const key in orc.orc_data.local_data) {            
            save_data[session_key][key] = orc.orc_data.local_data[key];
        }
        console.log("save_local_data:",save_data);
        Laya.LocalStorage.setItem(session_key,JSON.stringify(save_data[session_key]));        
    };

    public static load_local_data(){
        let session_key =  "orc_" + orc.orc_config.PLATFORM + "_" + orc.orc_config.GAME_NAME;
        let local_data_temp = Laya.LocalStorage.getItem(session_key);  
        if(local_data_temp == "" || local_data_temp == null)
        {
            //数据为空
            console.log('load_local_data数据为空',session_key,local_data_temp); 
        } 
        else
        {
            let local_data = JSON.parse(local_data_temp);      
            console.log("load_local_data:",local_data); 
            //讲本地的数据存入到local_data里去
            for (const key in orc.orc_data.local_data) {
                if(local_data[key])
                {
                    orc.orc_data.local_data[key] = local_data[key];
                }                
            }    
        }
    };

    public static log_local_data(){
        for (const key in orc.orc_data.local_data) {            
            console.log('log_local_data',key,orc.orc_data.local_data[key])
                           
        }    
    }
}